package com.surfin.safe.keyboard;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
import android.widget.Toast;

import androidx.annotation.StringRes;

import com.module.guard.GuardManager;

/**
 * 安全键盘工具类
 */
public class SafeKeyboardUtil {

    /**
     * 检查是否在调试模式
     */
    public static boolean isDebuggableMode(Context context) {
        return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    }

    /**
     * 检测是否Root
     */
    public static boolean isRoot() {
        return GuardManager.isRoot();
    }

    /**
     * 检测是否是模拟器
     */
    public static boolean isEmulator() {
        return GuardManager.isEmulator();
    }

    public static void showToast(Context context, @StringRes int resId) {
        Toast.makeText(context, resId, Toast.LENGTH_LONG).show();
    }

    public static int px2dip(float pxValue) {
        final float scale = Resources.getSystem().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5F);
    }
}
